package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.dubbo.mapper.BlackListMapper;
import com.tanhua.dubbo.mapper.UserInfoMapper;
import com.tanhua.model.db.BlackList;
import com.tanhua.model.db.UserInfo;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @auther : 白月尘
 * @date : 14:08  2021/10/18
 */
@DubboService
public class BlackListApiImpl implements BlackListApi{
    @Autowired
    private BlackListMapper blackListMapper;
    @Autowired
    private UserInfoMapper userInfoMapper;
    @Override
    public void deleteBlackList(long userId, long uid) {
        QueryWrapper<BlackList> queryWrapper=new QueryWrapper();
        queryWrapper.eq("user_id",userId).eq("black_user_id",uid);
        blackListMapper.delete(queryWrapper);
    }

    @Override
    public IPage<UserInfo> blacklist(int page, int pageSize,long userId) {
        Page pageParam=new Page(page,pageSize);
        return userInfoMapper.findBlackList(pageParam, userId);
    }
}
